<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      let treeData = [
        {
          children: [
            {
              children: [
                {
                  children: [
                    {
                      children: null,
                      id: 35,
                      parentId: 7,
                      type: 3,
                      subsystemCode: null,
                      name: "新增",
                      icon: "fa-home",
                      routeUrl: null,
                      perms: null,
                      sortOrder: 101,
                      flag: false,
                    },
                    {
                      children: null,
                      id: 36,
                      parentId: 7,
                      type: 3,
                      subsystemCode: null,
                      name: "编辑",
                      icon: "fa-home",
                      routeUrl: null,
                      perms: null,
                      sortOrder: 101,
                      flag: false,
                    },
                    {
                      children: null,
                      id: 37,
                      parentId: 7,
                      type: 3,
                      subsystemCode: null,
                      name: "详情",
                      icon: "fa-home",
                      routeUrl: null,
                      perms: null,
                      sortOrder: 101,
                      flag: false,
                    },
                    {
                      children: null,
                      id: 38,
                      parentId: 7,
                      type: 3,
                      subsystemCode: null,
                      name: "删除",
                      icon: "fa-home",
                      routeUrl: null,
                      perms: null,
                      sortOrder: 101,
                      flag: false,
                    },
                    {
                      children: null,
                      id: 39,
                      parentId: 7,
                      type: 3,
                      subsystemCode: null,
                      name: "授权",
                      icon: "fa-home",
                      routeUrl: null,
                      perms: null,
                      sortOrder: 101,
                      flag: false,
                    },
                  ],
                  id: 7,
                  parentId: 2,
                  type: 2,
                  subsystemCode: null,
                  name: "组织管理",
                  icon: "fa-home",
                  routeUrl: null,
                  perms: null,
                  sortOrder: 101,
                  flag: false,
                },
                {
                  children: [
                    {
                      children: null,
                      id: 30,
                      parentId: 8,
                      type: 3,
                      subsystemCode: null,
                      name: "新增",
                      icon: "fa-home",
                      routeUrl: null,
                      perms: null,
                      sortOrder: 101,
                      flag: false,
                    },
                    {
                      children: null,
                      id: 31,
                      parentId: 8,
                      type: 3,
                      subsystemCode: null,
                      name: "编辑",
                      icon: "fa-home",
                      routeUrl: null,
                      perms: null,
                      sortOrder: 101,
                      flag: false,
                    },
                    {
                      children: null,
                      id: 32,
                      parentId: 8,
                      type: 3,
                      subsystemCode: null,
                      name: "删除",
                      icon: "fa-home",
                      routeUrl: null,
                      perms: null,
                      sortOrder: 101,
                      flag: false,
                    },
                    {
                      children: null,
                      id: 33,
                      parentId: 8,
                      type: 3,
                      subsystemCode: null,
                      name: "详情",
                      icon: "fa-home",
                      routeUrl: null,
                      perms: null,
                      sortOrder: 101,
                      flag: false,
                    },
                    {
                      children: null,
                      id: 34,
                      parentId: 8,
                      type: 3,
                      subsystemCode: null,
                      name: "组织调整",
                      icon: "fa-home",
                      routeUrl: null,
                      perms: null,
                      sortOrder: 101,
                      flag: false,
                    },
                  ],
                  id: 8,
                  parentId: 2,
                  type: 2,
                  subsystemCode: null,
                  name: "人员管理",
                  icon: "fa-home",
                  routeUrl: null,
                  perms: null,
                  sortOrder: 101,
                  flag: false,
                },
              ],
              id: 2,
              parentId: 1,
              type: 2,
              subsystemCode: null,
              name: "组织人员",
              icon: "string",
              routeUrl: null,
              perms: null,
              sortOrder: 100,
              flag: false,
            },
            {
              children: [
                {
                  children: [
                    {
                      children: null,
                      id: 11,
                      parentId: 9,
                      type: 3,
                      subsystemCode: null,
                      name: "新增",
                      icon: "fa-home",
                      routeUrl: null,
                      perms: null,
                      sortOrder: 101,
                      flag: false,
                    },
                    {
                      children: null,
                      id: 12,
                      parentId: 9,
                      type: 3,
                      subsystemCode: null,
                      name: "解锁",
                      icon: "fa-home",
                      routeUrl: null,
                      perms: null,
                      sortOrder: 101,
                      flag: false,
                    },
                    {
                      children: null,
                      id: 13,
                      parentId: 9,
                      type: 3,
                      subsystemCode: null,
                      name: "启/停用",
                      icon: "fa-home",
                      routeUrl: null,
                      perms: null,
                      sortOrder: 101,
                      flag: false,
                    },
                    {
                      children: null,
                      id: 15,
                      parentId: 9,
                      type: 3,
                      subsystemCode: null,
                      name: "编辑",
                      icon: "fa-home",
                      routeUrl: null,
                      perms: null,
                      sortOrder: 101,
                      flag: false,
                    },
                    {
                      children: null,
                      id: 16,
                      parentId: 9,
                      type: 3,
                      subsystemCode: null,
                      name: "重置密码",
                      icon: "fa-home",
                      routeUrl: null,
                      perms: null,
                      sortOrder: 101,
                      flag: false,
                    },
                    {
                      children: null,
                      id: 17,
                      parentId: 9,
                      type: 3,
                      subsystemCode: null,
                      name: "删除",
                      icon: "fa-home",
                      routeUrl: null,
                      perms: null,
                      sortOrder: 101,
                      flag: false,
                    },
                    {
                      children: null,
                      id: 18,
                      parentId: 9,
                      type: 3,
                      subsystemCode: null,
                      name: "详情",
                      icon: "fa-home",
                      routeUrl: null,
                      perms: null,
                      sortOrder: 101,
                      flag: false,
                    },
                  ],
                  id: 9,
                  parentId: 3,
                  type: 2,
                  subsystemCode: null,
                  name: "用户管理",
                  icon: "fa-home",
                  routeUrl: null,
                  perms: null,
                  sortOrder: 101,
                  flag: false,
                },
                {
                  children: [
                    {
                      children: null,
                      id: 40,
                      parentId: 10,
                      type: 3,
                      subsystemCode: null,
                      name: "新增",
                      icon: "fa-home",
                      routeUrl: null,
                      perms: null,
                      sortOrder: 101,
                      flag: false,
                    },
                    {
                      children: null,
                      id: 41,
                      parentId: 10,
                      type: 3,
                      subsystemCode: null,
                      name: "编辑",
                      icon: "fa-home",
                      routeUrl: null,
                      perms: null,
                      sortOrder: 101,
                      flag: false,
                    },
                    {
                      children: null,
                      id: 42,
                      parentId: 10,
                      type: 3,
                      subsystemCode: null,
                      name: "删除",
                      icon: "fa-home",
                      routeUrl: null,
                      perms: null,
                      sortOrder: 101,
                      flag: false,
                    },
                    {
                      children: null,
                      id: 43,
                      parentId: 10,
                      type: 3,
                      subsystemCode: null,
                      name: "详情",
                      icon: "fa-home",
                      routeUrl: null,
                      perms: null,
                      sortOrder: 101,
                      flag: false,
                    },
                    {
                      children: null,
                      id: 44,
                      parentId: 10,
                      type: 3,
                      subsystemCode: null,
                      name: "授权",
                      icon: "fa-home",
                      routeUrl: null,
                      perms: null,
                      sortOrder: 101,
                      flag: false,
                    },
                    {
                      children: null,
                      id: 45,
                      parentId: 10,
                      type: 3,
                      subsystemCode: null,
                      name: "启/停用",
                      icon: "fa-home",
                      routeUrl: null,
                      perms: null,
                      sortOrder: 101,
                      flag: false,
                    },
                  ],
                  id: 10,
                  parentId: 3,
                  type: 2,
                  subsystemCode: null,
                  name: "角色管理",
                  icon: "fa-home",
                  routeUrl: null,
                  perms: null,
                  sortOrder: 101,
                  flag: false,
                },
              ],
              id: 3,
              parentId: 1,
              type: 2,
              subsystemCode: null,
              name: "用户权限",
              icon: "home",
              routeUrl: null,
              perms: null,
              sortOrder: 1,
              flag: false,
            },
          ],
          id: 1,
          parentId: null,
          type: 1,
          subsystemCode: null,
          name: "用户中心",
          icon: "string",
          routeUrl: null,
          perms: null,
          sortOrder: 1,
          flag: false,
        },
      ];
      function getNodeById(id, treeData) {
        for (const item of treeData) {
          if (id === item.id) {
            return item;
          }
          if (item.children) {
            let res = getNodeById(id, item.children);
            if (res) {
              return res;
            }
          }
        }
      }
      console.log(treeData);
      console.log(getNodeById(3, treeData));
    
    </script>
  </body>
</html>
